﻿using AutoMapper;
using B.S.NewMedical.Api.Write.Application.Command.ContentManagement.Carousel;
using B.S.NewMedical.Api.Write.Application.Command.ContentManagement.Department;
using B.S.NewMedical.Api.Write.Application.Command.ContentManagement.Hospital;
using B.S.NewMedical.Api.Write.Application.Command.ContentManagement.Patient;
using B.S.NewMedical.Api.Write.Application.Command.ContentManagement.Registration;
using B.S.NewMedical.Api.Write.Application.Command.User;
using B.S.NewMedical.Domain.Hospital;
using B.S.NewMedical.Domain.Doctor;
using B.S.NewMedical.Domain.User;
using B.S.NewMedical.Domain.Appointment;

namespace B.S.NewMedical.Api.Write.Files
{
    public class MapperProfiles : Profile
    {
        public MapperProfiles()
        {
            // 轮播图相关映射
            CreateMap<AddCarouselCommand, CarouselModel>()
                .ForMember(dest => dest.Id, opt => opt.Ignore())
                .ForMember(dest => dest.IsDeleted, opt => opt.MapFrom(src => false))
                .ForMember(dest => dest.CreateTime, opt => opt.MapFrom(src => DateTime.Now))
                .ForMember(dest => dest.UpdatePeople, opt => opt.Ignore())
                .ForMember(dest => dest.UpdateTime, opt => opt.Ignore());

            // 更新轮播图映射
            CreateMap<UpdateCarouselCommand, CarouselModel>()
                .ForMember(dest => dest.CreatePeople, opt => opt.Ignore())
                .ForMember(dest => dest.CreateTime, opt => opt.Ignore())
                .ForMember(dest => dest.IsDeleted, opt => opt.Ignore())
                .ForMember(dest => dest.UpdateTime, opt => opt.MapFrom(src => DateTime.Now));

            // 科室相关映射
            CreateMap<AddDepartmentCommand, DepartmentModel>()
                .ForMember(dest => dest.Id, opt => opt.Ignore())
                .ForMember(dest => dest.IsDeleted, opt => opt.MapFrom(src => false))
                .ForMember(dest => dest.CreateTime, opt => opt.Ignore()) // 在Handler中手动设置
                .ForMember(dest => dest.UpdatePeople, opt => opt.Ignore())
                .ForMember(dest => dest.UpdateTime, opt => opt.Ignore());

            // 更新科室映射
            CreateMap<UpdateDepartmentCommand, DepartmentModel>()
                .ForMember(dest => dest.CreatePeople, opt => opt.Ignore())
                .ForMember(dest => dest.CreateTime, opt => opt.Ignore())
                .ForMember(dest => dest.IsDeleted, opt => opt.Ignore())
                .ForMember(dest => dest.UpdateTime, opt => opt.MapFrom(src => DateTime.Now));

            // 医院相关映射
            CreateMap<AddHospitalCommand, HospitalModel>()
                .ForMember(dest => dest.Id, opt => opt.Ignore())
                .ForMember(dest => dest.IsDeleted, opt => opt.MapFrom(src => false))
                .ForMember(dest => dest.CreateTime, opt => opt.Ignore()) // 在Handler中手动设置
                .ForMember(dest => dest.UpdatePeople, opt => opt.Ignore())
                .ForMember(dest => dest.UpdateTime, opt => opt.Ignore());

            // 更新医院映射
            CreateMap<UpdateHospitalCommand, HospitalModel>()
                .ForMember(dest => dest.CreatePeople, opt => opt.Ignore())
                .ForMember(dest => dest.CreateTime, opt => opt.Ignore())
                .ForMember(dest => dest.IsDeleted, opt => opt.Ignore())
                .ForMember(dest => dest.UpdateTime, opt => opt.MapFrom(src => DateTime.Now));

            // 患者相关映射
            CreateMap<AddPatientCommand, PatientModel>()
                .ForMember(dest => dest.Id, opt => opt.Ignore())
                .ForMember(dest => dest.IsDeleted, opt => opt.MapFrom(src => false))
                .ForMember(dest => dest.CreateTime, opt => opt.Ignore()) // 在Handler中手动设置
                .ForMember(dest => dest.UpdatePeople, opt => opt.Ignore())
                .ForMember(dest => dest.UpdateTime, opt => opt.Ignore());

            // 更新患者映射
            CreateMap<UpdatePatientCommand, PatientModel>()
                .ForMember(dest => dest.CreatePeople, opt => opt.Ignore())
                .ForMember(dest => dest.CreateTime, opt => opt.Ignore())
                .ForMember(dest => dest.IsDeleted, opt => opt.Ignore())
                .ForMember(dest => dest.UpdateTime, opt => opt.MapFrom(src => DateTime.Now));

            // 挂号相关映射
            CreateMap<AddRegistrationCommand, B.S.NewMedical.Domain.Appointment.Registration>()
                .ForMember(dest => dest.Id, opt => opt.Ignore())
                .ForMember(dest => dest.IsDeleted, opt => opt.MapFrom(src => false))
                .ForMember(dest => dest.Slot_no, opt => opt.Ignore()) // 在Handler中手动设置
                .ForMember(dest => dest.Status, opt => opt.MapFrom(src => "待就诊"))
                .ForMember(dest => dest.Create_time, opt => opt.MapFrom(src => DateTime.Now));

            // 用户相关映射
            CreateMap<CreateUserCommand, UserModel>()
                .ForMember(dest => dest.Id, opt => opt.Ignore())
                .ForMember(dest => dest.IsDeleted, opt => opt.MapFrom(src => false))
                .ForMember(dest => dest.CreateTime, opt => opt.Ignore()) // 在Handler中手动设置
                .ForMember(dest => dest.CreatePeople, opt => opt.Ignore()) // 在Handler中手动设置
                .ForMember(dest => dest.UpdatePeople, opt => opt.Ignore())
                .ForMember(dest => dest.UpdateTime, opt => opt.Ignore())
                .ForMember(dest => dest.IsOnline, opt => opt.MapFrom(src => false));
        }
    }
}
